<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者，助力中小企业发展 
+----------------------------------------------------------------------
| Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
+----------------------------------------------------------------------
| 沃德代驾系统并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
+----------------------------------------------------------------------
| 组件-消息通知 开发者: 麦沃德科技-半夏 
+---------------------------------------------------------------------- -->

<template>
	<view class="component-message-list" :style="{'--theme-color': themeColor}">
		<view class="list-item flex align-items-center" v-for="(item, index) in showData" :key="index" @click="toDetails(item.order_id, item.name)">
			<view class="item-avatar">
				<image class="avatar" :src="item.avatar" mode="aspectFill"></image>
			</view>
			<view class="item-info flex-item">
				<view class="info-head flex align-items-center">
					<view class="head-name flex-item text-ellipsis">{{item.name}}</view>
					<view class="head-tag">{{item.latest_time}}</view>
				</view>
				<view class="info-content text-ellipsis">{{item.message}}</view>
			</view>
			<view class="item-point" v-if="item.status == 'unread'"></view>
			<view class="item-mask flex align-items-center" v-if="loading">
				<view class="mask-left"></view>
				<view class="mask-right flex-item">
					<view class="right-top flex align-items-center">
						<view class="top-left flex-item"></view>
						<view class="top-right"></view>
					</view>
					<view class="right-bottom"></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState } from "vuex"
	export default {
		name: "componentMessageList",
		props: ["showData", "channelType", "loading"],
		computed: {
			...mapState({
				themeColor: state => state.app.themeColor,
			})
		},
		methods: {
			// 跳转详情
			toDetails(id, name) {
				if (this.channelType == "driver") {
					this.$util.toPage({
						mode: 1,
						path: `/pages/driver/message/details?id=${id}&name=${name}`,
						isToken: true,
					})
				} else {
					this.$util.toPage({
						mode: 1,
						path: `/pages/passenger/message/details?id=${id}&name=${name}`,
						isToken: true,
					})
				}
			},
		}
	}
</script>

<style lang="scss">
	.component-message-list {
		.list-item {
			margin-top: 32rpx;
			border-radius: 32rpx;
			overflow: hidden;
			background: #FFF;
			padding: 32rpx;
			position: relative;

			&:first-child {
				margin-top: 0;
			}

			.item-avatar {
				width: 100rpx;
				height: 100rpx;

				.avatar {
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}
			}

			.item-info {
				margin-left: 32rpx;

				.info-head {
					.head-name {
						color: #242629;
						font-size: 32rpx;
						font-weight: 600;
						line-height: 44rpx;
					}

					.head-tag {
						color: #8D929C;
						font-size: 28rpx;
						font-weight: 600;
						line-height: 40rpx;
						margin-left: 16rpx;
					}
				}

				.info-content {
					margin-top: 16rpx;
					color: #8D929C;
					font-size: 28rpx;
					font-weight: 600;
					line-height: 40rpx;
				}
			}

			.item-point {
				position: absolute;
				top: 24rpx;
				left: 24rpx;
				border-radius: 50%;
				width: 16rpx;
				height: 16rpx;
				background: #DE2828;
			}

			.item-mask {
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				z-index: 9;
				background: #FFF;
				padding: 32rpx;

				.mask-left {
					width: 100rpx;
					height: 100rpx;
					background: #eee;
				}

				.mask-right {
					margin-left: 32rpx;

					.right-top {
						.top-left {
							flex: 1;
							height: 44rpx;
							background: #eee;
						}

						.top-right {
							width: 32%;
							height: 40rpx;
							margin-left: 24rpx;
							background: #eee;
						}
					}

					.right-bottom {
						margin-top: 16rpx;
						width: 100%;
						height: 40rpx;
						background: #eee;
					}
				}
			}
		}
	}
</style>